<?php
/*
while(1)
{
	$echo = getmypid() .'->'. date("YmHis").chr(10);
	echo $echo ;
	system('echo '.$echo.'> logp');
	sleep(5);
}*/
system('echo > logp');

while (true) {
	echo getmypid() .'run want data....................'.chr(10);
	$input = trim(fread(STDIN,5));
	echo getmypid() .'run check data'.chr(10);
	//if (feof(STDIN)) break;
	if ($input === false || strlen($input) === 0) {
		echo '======================================
		';
		echo chr(27).'[31mrun no data'.chr(27).'[0m'.chr(10);
		sleep(3);
		continue;
	}
	if($input=='close')
	{
		echo 'run closed'.chr(10);
		break;
	}
	echo 'run get data'.chr(10);
	// replase '<br />' to 'newline'
	$input = 'I_get_'.$input;
	fwrite(STDOUT, $input . "\n");
	
	$echo = getmypid() .'('.date('H_i_s').')'. $input.chr(10);
	//echo $echo ;
	//system('echo '.$echo.' > logp');
	file_put_contents('logp',$echo,FILE_APPEND);
	
 }